package com.site.util.Interceptor;

import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.site.util.constant.Constants;

/**
 * 前台登陆过滤器
 * @author jack
 *
 */
public class LoginInterceptor extends AbstractInterceptor {
 
	private static final long serialVersionUID = 8313355115891426453L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext actionContext = invocation.getInvocationContext();
        HttpServletResponse response= (HttpServletResponse) actionContext.get(StrutsStatics.HTTP_RESPONSE);
       
        Map<String,Object> session = actionContext.getSession();
        if (session != null && session.get(Constants.LOGIN_USER_FRONTEND) != null){
                return invocation.invoke();
        } else {
        	// 未登陆情况
        	return null;
        }
	}
}
